package no.monsen.client.common.util;

import java.text.MessageFormat;

import no.monsen.client.common.MonsenClientConstants;
import no.monsen.client.common.factory.MonsenPropertiesFactory;

public class MonsenVersionUtil {

	/**
	 * 
	 * @param The lates available version of Dagens Monsen from the remote server
	 * @return 
	 */
	public static String validateVersionNumber( String latest ) {
		Double latesVersionAvailable = Double.parseDouble( latest.trim() );
		Double clientVersion = Double.parseDouble( MonsenPropertiesFactory.getInstance().getProperty( MonsenClientConstants.MONSEN_CLIENT_VERSION ));
		if ( clientVersion < latesVersionAvailable ) {
			String tmpMessage = MonsenPropertiesFactory.getInstance().getProperty( MonsenClientConstants.MONSEN_LABEL_SYSTRAY_UPDATE_MESSAGE ) ;
			Object [] params = { MonsenPropertiesFactory.getInstance().getProperty( MonsenClientConstants.MONSEN_CLIENT_VERSION ) } ;
			
			return MessageFormat.format(tmpMessage, params);
		}
		return MonsenPropertiesFactory.getInstance().getProperty( MonsenClientConstants.MONSEN_LABEL_SYSTRAY_UPDATE_NOT_AVAILABLE_MESSAGE );
	}
}
